//
//  GTScreen.h
//  SampleApp2
//
//  Created by GXHC on 2023/6/27.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

#define IS_LANDSCAPE (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))

#define SCREEN_WIDTH (IS_LANDSCAPE ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT (IS_LANDSCAPE ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height)
#define UI(x) UIAdapter(x)
#define UIRect(x, y, width, height) UIRectAdapter(x, y, width, height)
#define IS_IPHONE_X (SCREEN_WIDTH == [GTScreen sizeFor58Inch].width && SCREEN_HEIGHT == [GTScreen sizeFor58Inch].height)
#define IS_IPHONE_XR (SCREEN_WIDTH == [GTScreen sizeFor61Inch].width && SCREEN_HEIGHT == [GTScreen sizeFor61Inch].height)
#define IS_IPHONE_XMAX (SCREEN_WIDTH == [GTScreen sizeFor65Inch].width && SCREEN_HEIGHT == [GTScreen sizeFor65Inch].height)
#define IS_IPHONE_X_XR_XMAX (IS_IPHONE_X || IS_IPHONE_XR || IS_IPHONE_XMAX)

#define STATUSBARHEIGHT (IS_IPHONE_X_XR_XMAX ? 44 : 20)

static inline NSInteger  UIAdapter (float x) {
	CGFloat scale = 414 / SCREEN_WIDTH;
	return (NSInteger)x/scale;
}

static inline CGRect UIRectAdapter(x, y, width, height){
	return (CGRectMake(UIAdapter(x), UIAdapter(y), UIAdapter(width), UIAdapter(height)));

}
@interface GTScreen : NSObject

+(CGSize) sizeFor65Inch;
+(CGSize) sizeFor61Inch;
+(CGSize) sizeFor58Inch;
@end

NS_ASSUME_NONNULL_END
